import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		tabbar_list: [{
				iconPath: 'home',
				selectedIconPath: 'home-fill',
				text: '首页',
				customIcon: false,
				pagePath: '/pages/index/index'
			},
			{
				iconPath: 'grid',
				selectedIconPath: 'grid-fill',
				text: '分类',
				customIcon: false,
				pagePath: '/pages/cate/index'
			},
			{
				iconPath: 'shopping-cart',
				selectedIconPath: 'shopping-cart-fill',
				text: '购物车',
				customIcon: false,
				pagePath: '/pages/cart/index'
			},
			{
				iconPath: 'account',
				selectedIconPath: 'account-fill',
				text: '我的',
				customIcon: false,
				pagePath: '/pages/user/index'
			}
		],
		hasLogin: !!uni.getStorageSync('token'),
		wxUserInfo: uni.getStorageSync('wxUserInfo')||{},
		wxOpenId:uni.getStorageSync('wxOpenId') || '',
		token:uni.getStorageSync('token') || '',
		expireTime:uni.getStorageSync('expireTime') || '',
		basicSet:{
			themeStyle:{
				theme:'red',
				color_o:'#FD463E'
			}
		},
		
	},
	mutations: {
		// 设置微信用户信息
		commit_wxUserInfo(state, wxUserInfo) {
			state.wxUserInfo = wxUserInfo
			uni.setStorageSync('wxUserInfo', wxUserInfo);
		},
		// 设置微信openID
		commit_wxOpenId(state, wxOpenId) {
			state.wxOpenId = wxOpenId
			uni.setStorageSync('wxOpenId', wxOpenId);
		},
		// 设置登录token
		commit_token(state, token) {
			state.token = token
			uni.setStorageSync('token', token);
		},
		// 设置token失效时长
		commit_expireTime(state, expireTime) {
			state.expireTime = expireTime
			uni.setStorageSync('expireTime', expireTime);
		},
		// 判断登录状态
		commit_hasLogin(state, hasLogin) {
			state.hasLogin = hasLogin
		},
		// 商城基本设置
		commit_basicSet(state, basicSet) {
			state.basicSet = basicSet
		},
	},
	actions: {}
})
export default store
